package com.elsa.smart_buffet.test1;

import com.elsa.smart_buffet.mapper.*;
import com.elsa.smart_buffet.pojo.MenuOrder;
import com.elsa.smart_buffet.service.DayMpService;
import com.elsa.smart_buffet.service.MenuIncomeExpenseService;
import com.elsa.smart_buffet.service.SaleEchartsService;
import com.elsa.smart_buffet.service.UserPersonalService;
import com.elsa.smart_buffet.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @ClassName : testMenuOrder  //类名
 * @Author : elsa //作者
 */
@RunWith(SpringRunner.class)
@WebAppConfiguration
@SpringBootTest()
@Slf4j
public class testMenuOrder {

    @Autowired
    private MenuOrderMapper menuOrderMapper;

    @Autowired
    private MenuIncomeExpenseService menuIncomeExpenseService;

    @Autowired
    private UserPersonalMapper userPersonalMapper;

    @Autowired
    private UserPersonalService userPersonalService;

    @Autowired
    private TradeEchartsMapper tradeEchartsMapper;

    @Autowired
    private SaleEchartsMapper saleEchartsMapper;

    @Autowired
    private SaleEchartsService saleEchartsService;

    @Autowired
    private DayMpService dayMpService;

    @Test
    public void testMenuOrder() {
        System.out.println(menuOrderMapper.selectMenuOrderMapperFromOrder("27"));
        List<MenuOrder> list = menuOrderMapper.selectMenuOrderMapperFromOrder("27");
        String res = "";
        for (int i = 0; i < list.size(); i++) {
            if(i != list.size() - 1) {
                res += list.get(i).getMName() + ",";
            } else {
                res += list.get(i).getMName();
            }
        }
        log.info(res);
    }

    @Test
    public void testMenuIncomeExpenseService() {
        menuIncomeExpenseService.getMenuIncomeExpenseByTime("20230323");
    }

    @Test
    public void  testUserPersonalMapper() {
        log.info(String.valueOf(userPersonalMapper.getUserPersonalByTime("20230323")));
    }

    @Test
    public void testUserPersonalService() {
        log.info(String.valueOf(userPersonalService.getUserPersonalByTime("20230323")));
    }

    @Test
    public void testTradeEchartsMapper() {
        log.info(String.valueOf(tradeEchartsMapper.getTradeEchartsByPriceAndDate("30","39","20230323")));
    }

    @Test
    public void testOrderTime() {
//        Date date = new Date(DateUtil.now().);
//        log.info(String.valueOf(date));
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.sql.Date ctime2 = new java.sql.Date(new java.util.Date().getTime());
        System.out.println(df.format(ctime2));
//        java.util.Date utilDate = new java.util.Date();  //获取当前时间
//        java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
//        System.out.println(sqlDate);
//        java.sql.Date now= new java.sql.Date(System.currentTimeMillis());
//        System.out.println(now);
//        java.util.Date datetime=new java.util.Date();
//        System.out.println(datetime);
    }

    @Test
    public void testSaleEchartsMapper() {
        log.info(String.valueOf(saleEchartsMapper.getSaleEchartsStatsByDate("20230330")));
    }

    @Test
    public void testSaleEchartsByMonth() {
        log.info(String.valueOf(saleEchartsMapper.getSaleEchartsStatsByMonth("202305")));
    }

    @Test
    public void testSaleEchartsService() {
        log.info(String.valueOf(saleEchartsService.getSaleEchartsByDate("2023-03-27")));
    }

    @Test
    public void testDayMpService () {
        dayMpService.getDayMpNumByDate("20230330");
    }

}
